package com.xiaoxin.suma.utils;

import android.text.TextUtils;

import com.blankj.utilcode.util.SPUtils;

/**
 * Created by ljm on 2017/5/23.
 */

public class DataManger {
    public static SPUtils spUtils;
    private static String token;
    private static String name;
    private static final String TOKEN = "token";
    private static final String USER_NAME = "name";

    public static String getToken() {
        if (TextUtils.isEmpty(token)) {
            token = spUtils.getString(TOKEN);
        }
        return token;
    }

    public static void setToken(String token) {
        DataManger.token = token;
        spUtils.put(TOKEN, token);
    }

    public static String getUserName() {
        if (TextUtils.isEmpty(name)) {
            name = spUtils.getString(USER_NAME);
        }
        return name;
    }

    public static void setUserName(String userName) {
        name = userName;
        spUtils.put(USER_NAME, userName);
    }

    public static void out() {
        token = name = null;
        spUtils.clear();
    }
}
